package com.foreknow.util;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;

/**
 * @author ttc
 *这个类根据data值和表头coulum制动态表
 */
public class PropertyJtable {
    private static PropertyJtable jtable = null;
    private DefaultTableModel model = new DefaultTableModel();
    private PropertyJtable() {
    }

    public static PropertyJtable getJtable() {
        if (jtable == null) {
            jtable = new PropertyJtable();
        }
        return jtable;
    }

    /**
     * 根据data，coulum制作一个新动态表
     * @Object data
     * @String column
     * @JTable
     */
    public JTable newJtable(Object[][] data, String[] column) {
        //DefaultTableModel
        model.setDataVector(data, column);
        JTable jtable = new JTable(model);
        return jtable;
    }

    /**
     * 更新动态表
     * @Object data
     * @String column
     */
    public void update(Object[][] data, String[] column) {
        model.setDataVector(data, column);
    }
}